package com.lovi.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;

/**
 * 实体类，需要做JR303校验
 */
@Data
@TableName("user") //mp带有的
public class User implements Serializable {
    //序列化:性能优化
    public static final Long serialVersionUID =1L;

    @TableId(type = IdType.AUTO)
    @TableField("user_id")
    @JsonProperty("user_id")
    private String userId;
    @Length(min = 4) //长度校验
    private String userName;
    //JsonInclude.Include.NON_NULL[不为空就生成json,null则不生成，当他为null相当于忽略json
    @NotBlank
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String password;
    @NotBlank
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String userPhonenumber;
}
